package com.restaurant.application.indexes.couponmanagelist.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class CouponManageListData implements PickableBean {

    public static final String FN_ID = "id";
    public static final String FN_NAME = "name";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
             FN_ID,
             FN_NAME);

    private String id;
    private String name;

    public CouponManageListData(String id, String name) {
        setId(id);
        setName(name);
    }

    public CouponManageListData() {
    }

    public CouponManageListData duplicate() {
        CouponManageListData result = new CouponManageListData();
        result.id = this.id;
        result.name = this.name;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getId() {
        return id;
    }

    public void  setId(String value) {
        this.id = value;
    }

    public CouponManageListData withId(String value) {
        setId(value);
        return this;
    }

    public CouponManageListData withId(String value, String defaultValue) {
        setId(value == null ? defaultValue : value);
        return this;
    }

    public String getName() {
        return name;
    }

    public void  setName(String value) {
        this.name = value;
    }

    public CouponManageListData withName(String value) {
        setName(value);
        return this;
    }

    public CouponManageListData withName(String value, String defaultValue) {
        setName(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch(name) {
        case "id": return getId();
        case "name": return getName();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if(!(o instanceof CouponManageListData)) return false;
        return signature().equals(((CouponManageListData)o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean CouponManageListData has no signature defined, no hash code or equals possible.");
    }
}
